<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='../js/vue.js'></script>

</head>
<body>
    <div id='app'>
        <a href="#/index">主页</a>
        <a href="#/category">分类</a>
        <a href="#/post">post</a>
        <component :is="comName"></component>
    </div>
    <script type='text/javascript'>
        const index = {
            template: `<div>
                <h1>主页页面</h1>
            </div>`
        }
        const category = {
            template: `<div>
                <h1>分类页面</h1>
            </div>`
        }
        const post = {
            template: `<div>
                <h1>文章页面</h1>
            </div>`
        }

        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue',
                comName: 'index'
            },
            components: {
                index,
                category,
                post
            }
        });

        window.onhashchange = function() {
            // console.log(location.hash);
            vm.comName = location.hash.slice(2);
        }
    </script>
</body>
</html>